package link.cocoon.common.util;

import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.pegdown.PegDownProcessor;

public class MarkdownUtil {

  private final static PegDownProcessor peg = new PegDownProcessor(Integer.MAX_VALUE);


  public static String toText(String md){
    String html = toHtml(md);
    return cleanHtmlTag(html);
  }

  public static String toHtml(String md) {
    return peg.markdownToHtml(md);
  }

  public static String cleanHtmlTag(String html) {
    return Jsoup.clean(html, new Whitelist());
  }
}
